<template>
  <div>
    <table class="table tabel-bordered" style="text-align: center;">
    <tr>
        <td align="right">账号</td>
        <td >
            <input type="text" v-model="getshu.state.U_Name" >

        </td>
    </tr>
    <tr>
        <td align="right" >密码</td>
        <td >
            <input type="text" v-model="getshu.state.U_Pwd" >

        </td>
    </tr>
    <tr>
        <td align="right"></td>
        <td >
            <input type="button" value="注册" class="btn btn-success" @click="zhuce()">

        </td>
    </tr>
<!-- <tr>
  <td>

    <select>

<option v-for="shu in get":value="shu.U_id">{{ item. U_Name}}</option>

    </select>

  </td>
</tr> -->



</table>

  </div>
</template>

<script setup lang="ts">

import router from '@/router';
import axios from'axios'
import {reactive,toRefs,onMounted}from'vue'

// import {reactive,toRefs}from 'vue'

onMounted(()=>{

  okselect()

})


//集合存值
let getshu=reactive({

        state:{
          U_Name:'',
          U_Pwd:'',

        }
,get:[





]


})






let {state,get}=toRefs(getshu)


console.log(state)



//  注册
const zhuce=()=>{
    if(state.value.U_Name=="")
    {
      alert('账号不能为空')
      return;
    }
    if(state.value.U_Pwd=="")
    {
      alert('密码不能为空')
      return;
    }

    let reg=/^[a-zA-Z]\w{5,15}$/

    if(reg.test(state.value.U_Pwd)==false)
    {
      alert('密码不符合要求')
      return;
    }

    axios({
      url:"https://localhost:44385/api/Default/showLogin",
      method: 'post',
        data:state.value,
    })
    .then((res)=>{

        if(res.data.data>0)
        {
          alert('注册成功')
          router.push("/Login")
        }
        if(res.data.data==-1){
          alert('注册失败')
        }

      

  
    })
    .catch((err)=>{

      alert('不成功');


    })


}

// 下拉框
const okselect=()=>{


axios({

        url:"",
        method:"get",



    



    
})

.then((res)=>{

  get.value=res.data.U_Name
  get.value=res.data.U_id
})


}




</script>

<style scoped>

</style>